﻿using System;
using System.IO;
using SaveDataStructures;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

// Token: 0x02000388 RID: 904
public class LoadSceneUI : MonoBehaviour
{
	// Token: 0x060017A0 RID: 6048 RVA: 0x0009629C File Offset: 0x0009449C
	private void Start()
	{
		IOManager instance = IOManager.Instance;
		string[] listLoadableSaveFiles = instance.GetListLoadableSaveFiles();
		GameObject gameObject = base.GetComponentInChildren<GridLayoutGroup>().gameObject;
		for (int i = 0; i < listLoadableSaveFiles.Length; i++)
		{
			Button button = UnityEngine.Object.Instantiate<Button>(this.buttonPrefab);
			button.transform.SetParent(gameObject.transform, false);
			TextMeshProUGUI componentInChildren = button.GetComponentInChildren<TextMeshProUGUI>();
			string path = listLoadableSaveFiles[i];
			string[] array = path.Split(new char[]
			{
				Path.DirectorySeparatorChar
			});
			string text = array[array.Length - 1];
			text = text.Replace(".save", string.Empty);
			componentInChildren.text = text.Replace(".json", string.Empty);
			button.onClick.AddListener(delegate()
			{
				this.OnClickLoadScene(path);
			});
		}
	}

	// Token: 0x060017A1 RID: 6049 RVA: 0x00096384 File Offset: 0x00094584
	private void OnClickLoadScene(string scene)
	{
		Debug.Log("Load Scene: " + scene);
		SaveData saveData = SavedScenesManager.Instance.LoadSaveData(scene);
		this.charUI.gameObject.SetActive(true);
		this.charUI.GetComponent<UICharSelect>().loadScene = saveData.scene;
		base.transform.parent.gameObject.SetActive(false);
	}

	// Token: 0x040019E5 RID: 6629
	public Button buttonPrefab;

	// Token: 0x040019E6 RID: 6630
	public Canvas charUI;

	// Token: 0x040019E7 RID: 6631
	public Canvas menuUI;
}
